package org.xx.armory.config.log4j2;

import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;

import static org.xx.armory.commons.Validators.notNull;

public final class Log4j2Section {
    private final Set<LoggerSection> loggers;
    private final Set<AppenderSection> appenders;
    private RootLoggerSection root;

    public Log4j2Section() {
        this.appenders = new LinkedHashSet<>();
        this.loggers = new LinkedHashSet<>();
    }

    public RootLoggerSection getRoot() {
        return root;
    }

    public void setRoot(RootLoggerSection root) {
        this.root = root;
    }

    public final Set<AppenderSection> getAppenders() {
        return Collections.unmodifiableSet(appenders);
    }

    public final Set<LoggerSection> getLoggers() {
        return Collections.unmodifiableSet(loggers);
    }

    public final void addLogger(LoggerSection item) {
        this.loggers.add(notNull(item, "item"));
    }

    public final void addAppender(AppenderSection item) {
        this.appenders.add(notNull(item, "item"));
    }
}
